﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUS;
using TuyenDungViecLam.CommonResource;
namespace TuyenDungViecLam.Admin
{
    public partial class CacTinSaiPham : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LienKetDuLieu();
            }
        }

        private void LienKetDuLieu()
        {
            dscongviec.DataSource = ChiTietCongViec_BUS.DanhSachCacTinSaiPham();
            dscongviec.DataBind();
        }

        protected void dscongviec_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            dscongviec.PageIndex = e.NewPageIndex;
            LienKetDuLieu();
        }

        protected void dscongviec_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "chon")
            {
                for (int i = 0; i < dscongviec.Rows.Count; i++)
                {
                    CheckBox cbchon = (CheckBox)dscongviec.Rows[i].FindControl("cbchon");
                    cbchon.Checked = true;
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dscongviec.Rows.Count; i++)
            {
                Label lbmacongviec = (Label)dscongviec.Rows[i].Cells[0].FindControl("lbmacongviec");
                CheckBox cbchon = (CheckBox)dscongviec.Rows[i].Cells[0].FindControl("cbchon");
                if (cbchon.Checked == true)
                {
                    ChiTietCongViec_BUS.ChoPhepDangLaiTin(lbmacongviec.Text);
                }
            }
            Alert.Show("Đã cho đăng các công việc trở lại !");
            LienKetDuLieu();

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dscongviec.Rows.Count; i++)
            {
                Label lbmacongviec = (Label)dscongviec.Rows[i].Cells[0].FindControl("lbmacongviec");
                CheckBox cbchon = (CheckBox)dscongviec.Rows[i].Cells[0].FindControl("cbchon");
                if (cbchon.Checked == true)
                {
                    ChiTietCongViec_BUS.HuyCongViec(lbmacongviec.Text);
                }
            }
            Alert.Show("Đã không cho đăng các công việc !");
            LienKetDuLieu();

        }
    }
}
